#ifndef _PARTHUS_LM_FEATURES_
#define _PARTHUS_LM_FEATURES_

/**************************************************************************
 * MODULE NAME:    lm_features.h
 * PROJECT CODE:   BlueStream
 * DESCRIPTION:    Manipulatation of the features
 * AUTHOR:         Gary Fleming
 * DATE:           22-12-1999
 *
 * SOURCE CONTROL: $Id: lmp_features.h,v 1.7 2008/12/31 10:04:57 tianwq Exp $
 *
 * LICENSE:
 *   This source code is copyright (c) 2000-2004 Ceva Inc.
 *   All rights reserved.
 *
 *************************************************************************/

#include "sys_types.h"
#include "lmp_types.h"

typedef u_int8 t_features[8];

/* byte 0 */
#define SLOT_3_PACKETS_MASK                               0x01
#define SLOT_5_PACKETS_MASK                               0x02
#define ENCRYPTION_MASK                                   0x04
#define SLOT_OFFSET_MASK                                  0x08
#define TIMING_ACCURACY_MASK                              0x10
#define SWITCH_ROLE_MASK                                  0x20
#define HOLD_MODE_MASK                                    0x40
#define SNIFF_MODE_MASK                                   0x80
/* byte 1 */
#define PARK_MODE_MASK                                    0x01
#define RSSI_MASK                                         0x02
#define RATE_CHANGE_MASK                                  0x04
#define SCO_LINK_MASK                                     0x08
#define HV2_PACKETS_MASK                                  0x10
#define HV3_PACKETS_MASK                                  0x20
#define U_LAW_MASK                                        0x40
#define A_LAW_MASK                                        0x80
/* byte 2 */
#define CVSD_MASK                                         0x01
#define PAGING_SCHEME_MASK                                0x02
#define POWER_CONTROL_MASK                                0x04
#define TRANSPARENT_SYN_DATA_MASK                         0x08
/* skip flow control lag */
#define BROADCAST_ENCRYPTION_MASK                         0x80
/* byte 3 */
#define SCATTER_MODE_MASK                                 0x01
#define EDR_ACL_2MBPS_MODE_MASK                           0x02
#define EDR_ACL_3MBPS_MODE_MASK                           0x04
#define ENHANCED_INQ_SCAN_MASK                            0x08
#define INTERLACED_INQ_SCAN_MASK                          0x10
#define INTERLACED_PAGE_SCAN_MASK                         0x20
#define RSSI_WITH_INQ_RESULTS_MASK                        0x40
#define ESCO_LINK_MASK                                    0x80
/* byte 4 */
#define EV4_PACKETS_MASK                                  0x01
#define EV5_PACKETS_MASK                                  0x02
#define ABSENCE_MASK                                      0x04
#define AFH_CAPABLE_SLAVE_MASK                            0x08
#define AFH_CLASSIFICATION_SLAVE_MASK                     0x10
#define ALIAS_AUTHENTICATION_MASK                         0x20
#define ANONYMITY_MODE_MASK                               0x40
#define _3_SLOT_EDR_ACL_PACKETS_MASK                      0x80
/* byte 5 */
#define _5_SLOT_EDR_ACL_PACKETS_MASK                      0x01
#define SNIFF_SUBRATING_MASK                              0x02
#define PAUSE_ENCRYPTION_FEATURE_MASK                     0x04
#define AFH_CAPABLE_MASTER_MASK                           0x08
#define AFH_CLASSIFICATION_MASTER_MASK                    0x10
#define EDR_ESCO_2MBPS_MODE_MASK                          0x20
#define EDR_ESCO_3MBPS_MODE_MASK                          0x40
#define _3_SLOT_EDR_ESCO_PACKETS_MASK                     0x80
/* byte 6 */
#define EXTENDED_INQUIRY_RESPONSE_MASK                    0x01
#define SECURE_SIMPLE_PAIRING_MASK                        0x08
#define ENCAPSULATED_PDU_MASK                             0x10
#define ERRONEOUS_DATA_REPORTING_MASK                     0x20
#define NONFLUSHABLE_PACKET_BOUNDARY_FLAG_MASK            0x40
/* byte 7 */
#define LINK_SUPERVISION_TIMEOUT_CHANGED_EVENT_MASK       0x01
#define INQUIRY_RESPONSE_TX_POWER_LEVEL_MASK              0x02
#define ENHANCED_POWER_CONTROL_MASK                       0x04
#define EXTENDED_FEATURE                                  0x80

/* byte 0 */
#define mFeat_Check_3_Slot(features)                    ( features[0] & SLOT_3_PACKETS_MASK )
#define mFeat_Check_5_Slot(features)                    ( features[0] & SLOT_5_PACKETS_MASK )
#define mFeat_Check_Encryption(features)                ( features[0] & ENCRYPTION_MASK     )
#define mFeat_Check_Slot_Offset(features)               ( features[0] & SLOT_OFFSET_MASK    )
#define mFeat_Check_Timing_Accuracy(features)           ( features[0] & TIMING_ACCURACY_MASK)
#define mFeat_Check_Role_Switch(features)               ( features[0] & SWITCH_ROLE_MASK    )
#define mFeat_Check_Hold_Mode(features)                 ( features[0] & HOLD_MODE_MASK      )
#define mFeat_Check_Sniff_Mode(features)                ( features[0] & SNIFF_MODE_MASK     )
/* byte 1 */
#define mFeat_Check_Park_State(features)                ( features[1] & PARK_MODE_MASK      )
#define mFeat_Check_RSSI(features)                      ( features[1] & RSSI_MASK           )
#define mFeat_Check_CQDDR(features)                     ( features[1] & RATE_CHANGE_MASK    )
#define mFeat_Check_Sco_Link(features)                  ( features[1] & SCO_LINK_MASK       )
#define mFeat_Check_HV2_Packets(features)               ( features[1] & HV2_PACKETS_MASK    )
#define mFeat_Check_HV3_Packets(features)               ( features[1] & HV3_PACKETS_MASK    )
#define mFeat_Check_U_Law(features)                     ( features[1] & U_LAW_MASK          )
#define mFeat_Check_A_Law(features)                     ( features[1] & A_LAW_MASK          )
/* byte 2 */
#define mFeat_Check_CVSD(features)                      ( features[2] & CVSD_MASK           )
#define mFeat_Check_Paging_System(features)             ( features[2] & PAGING_SCHEME_MASK  )
#define mFeat_Check_Power_Control(features)             ( features[2] & POWER_CONTROL_MASK  )
#define mFeat_Check_Transparent_Sync_Data(features)     ( features[2] & TRANSPARENT_SYN_DATA_MASK )
#define mFeat_Check_Broadcast_Encryption(features)      ( features[2] & BROADCAST_ENCRYPTION_MASK )
/* byte 3 */
#define mFeat_Check_Scatter_Mode(features)              ( features[3] & SCATTER_MODE_MASK   )
#define mFeat_Check_EDR_ACL_2Mbps_Mode(features)        ( features[3] & EDR_ACL_2MBPS_MODE_MASK   )
#define mFeat_Check_EDR_ACL_3Mbps_Mode(features)        ( features[3] & EDR_ACL_3MBPS_MODE_MASK   )
#define mFeat_Check_Enhanced_Inquiry_Scan(features)     ( features[3] & ENHANCED_INQ_SCAN_MASK )
#define mFeat_Check_Interlaced_Inquiry_Scan(features)   ( features[3] & INTERLACED_INQ_SCAN_MASK )
#define mFeat_Check_Interlaced_Page_Scan(features)      ( features[3] & INTERLACED_PAGE_SCAN_MASK )
#define mFeat_Check_RSSI_With_Inquiry_Results(features) ( features[3] & RSSI_WITH_INQ_RESULTS_MASK )
#define mFeat_Check_eSco_Link(features)                 ( features[3] & ESCO_LINK_MASK      )
/* byte 4 */
#define mFeat_Check_EV4_Packets(features)               ( features[4] & EV4_PACKETS_MASK    )
#define mFeat_Check_EV5_Packets(features)               ( features[4] & EV5_PACKETS_MASK    )
#define mFeat_Check_Absence_Masks(features)             ( features[4] & ABSENCE_MASK  )
#define mFeat_Check_AFH_Capable_Slave(features)         ( features[4] & AFH_CAPABLE_SLAVE_MASK )
#define mFeat_Check_AFH_Classification_Slave(features)  ( features[4] & AFH_CLASSIFICATION_SLAVE_MASK )
#define mFeat_Check_Alias_Authentication(features)      ( features[4] & ALIAS_AUTHENTICATION_MASK )
#define mFeat_Check_Anonymity_Mode(features)            ( features[4] & ANONYMITY_MODE_MASK )
#define mFeat_Check__3_SLOT_EDR_ACL_PACKETS(features)   ( features[4] & _3_SLOT_EDR_ACL_PACKETS_MASK   )
/* byte 5 */
#define mFeat_Check__5_SLOT_EDR_ACL_PACKETS(features)   ( features[5] & _5_SLOT_EDR_ACL_PACKETS_MASK   )
#define mFeat_Check_Sniff_Subrating(features)           ( features[5] & SNIFF_SUBRATING_MASK)
#define mFeat_Check_Pause_Encryption(features)          ( features[5] & PAUSE_ENCRYPTION_FEATURE_MASK)
#define mFeat_Check_AFH_Capable_Master(features)        ( features[5] & AFH_CAPABLE_MASTER_MASK )
#define mFeat_Check_AFH_Classification_Master(features) ( features[5] & AFH_CLASSIFICATION_MASTER_MASK )
#define mFeat_Check_EDR_ESCO_2MBPS_MODE(features)       ( features[5] & EDR_ESCO_2MBPS_MODE_MASK   )
#define mFeat_Check_EDR_ESCO_3MBPS_MODE(features)       ( features[5] & EDR_ESCO_3MBPS_MODE_MASK   )
#define mFeat_Check__3_SLOT_EDR_ESCO_PACKETS(features)  ( features[5] & _3_SLOT_EDR_ESCO_PACKETS_MASK   )
/* byte 6 */
#define mFeat_Check_Extend_Inquiry_Response(features)   ( features[6] & EXTENDED_INQUIRY_RESPONSE_MASK )
#define mFeat_Check_Secure_Simple_Pairing(features)     ( features[6] & SECURE_SIMPLE_PAIRING_MASK )
#define mFeat_Check_Encapsulated(features)              ( features[6] & ENCAPSULATED_PDU_MASK)
#define mFeat_Check_Erroneous_Data_Reporting(features)  ( features[6] & ERRONEOUS_DATA_REPORTING_MASK)
#define mFeat_Check_Nonflushable_Packet_Boundary_Flag(features)           ( features[6] & NONFLUSHABLE_PACKET_BOUNDARY_FLAG_MASK)

/* byte 7 */
#define mFeat_Check_Link_Supervision_Timeout_Changed_Event(features)      ( features[7] & LINK_SUPERVISION_TIMEOUT_CHANGED_EVENT_MASK )
#define mFeat_Check_Inquiry_Response_TX_Power_Level(features)             ( features[7] & INQUIRY_RESPONSE_TX_POWER_LEVEL_MASK )
#define mFeat_Check_Enhanced_Power_Control(features)                      ( features[7] & ENHANCED_POWER_CONTROL_MASK )
#define mFeat_Check_Extended_Features(features)                           ( features[7] & EXTENDED_FEATURE )

#define mLMPfeat_Is_Remote_Feature_Supported(feature_set, lmp_feature_id) \
((feature_set)[(lmp_feature_id)>>8] & (u_int8) (lmp_feature_id&0xFF))

#endif

